package org.example.controller;

import org.example.entity.SysMenu;
import org.example.entity.SysMenuByName;
import org.example.service.MenuSelectService;
import org.example.service.MenuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuSelectService menuSelectService;

    @Resource
    private MenuService menuService;

    @GetMapping("/{type}")
    public List<SysMenuByName> sysMenuByNameLis(@PathVariable("type") Integer type){

        List<SysMenuByName> sysMenuByNames = menuService.sysMenuByNameList(type);

        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"+type);

        return sysMenuByNames;
    }

    @GetMapping("/getAll")
    public List<SysMenu>  getAll(){
        return menuService.getAll();
    }

    @GetMapping()
    public List<SysMenuByName> sysMenuByNameList(){


        List<SysMenuByName> sysMenuByNames =  menuSelectService.sysMenuByNameList();

        return sysMenuByNames;
    }
}
